//src/main/java/com/cuit/blog/service/PictureService.java1
package com.cuit.blog.service;

import com.cuit.blog.dao.PictureRespository;
import com.cuit.blog.entity.Pictrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PictureService {
    @Autowired
    PictureRespository pictureRespository;

    public List<Pictrue> findAll(){return pictureRespository.findAll();}
    public void save(Pictrue picture) {
        pictureRespository.save(picture);
    }
    public int getNextId() {

        return (int) (pictureRespository.count() + 1);
    }
    public Pictrue findById(Integer id) {
        return pictureRespository.findById(id).orElse(null);
    }

    public void deleteById(Integer id) {
        pictureRespository.deleteById(id);
    }
}
